<?php
/**
 *
 *
 *
 */
namespace Yz\modules\Users;
class Model_Default
    extends \Yz_Model_Abstract
{


    /************************************
     *         Public methods          *
     ************************************/

    /** Model's constructor with fields definition
     *  @param Yz_Module_Interface $module
     */
    protected function init()
    {
        debug();
        parent::init();
        $d =& $this->__dict__;
        $d['id']            = new \Yz_Property_Id();
        $d['login']         = new \Yz_Property_String();
        $d['passwordMD5']   = new \Yz_Property_String();
        $d['lastLoginTime'] = new \Yz_Property_Timestamp();
        $d['lastLoginIP']   = new \Yz_Property_String();
        //$d['roles']         = new \Yz_Property_ManyToMany();
        return $this;
    }

    /**
     *  @param string $login
     *  @return \ns\Item_User
     *  @throws ItemNotFound
     */
    public function fetchUserByLogin($login)
    {
        debug();
        $values = $this
            ->selectAction('SelectByLogin')
            ->setLogin($login)
            ->perform()
            ->fetch()
        ;
        return $this->itemFromValues($values);
    }

} // class
